<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>initializeNDArray</title>
</head>
<body>
    <div id="content"></div>
    <script>
        const initializeNDArray = (val,...args) => args.length === 0 ? val : Array.from({ length:args[0] }).map(() => initializeNDArray(val,...args.slice(1)));
        document.querySelector('#content').innerHTML = `
            <div class="result-1">
                initializeNDArray(5, 2):
                &nbsp;&nbsp;
                ${JSON.stringify(initializeNDArray(1, 3))}
            </div>
            <div class="result-2">
                initializeNDArray(5, 2, 2, 2):
                &nbsp;&nbsp;
                ${JSON.stringify(initializeNDArray(5, 2, 2, 2))}    
            </div>
        `;
    </script>
</body>
</html>